package com.ambitor.ipro.demo;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Test {
	protected static final Logger logger = LoggerFactory
			.getLogger(TestCallClient.class);

	public static void main(String[] args) {
		String text = "嘻嘻@{title}哈哈@{title}拉拉";
		text = StringUtils.replace(text, "@{title}", "xx");
		System.out.println("text==" + text);
	}

	public static Date randomDate(Date satatDate, Date endDate) {
		long millsecs = 0;
		if (satatDate.getTime() >= endDate.getTime()) {
			millsecs = random(endDate.getTime(), satatDate.getTime());
		} else {
			millsecs = random(satatDate.getTime(), endDate.getTime());
		}
		return new Date(millsecs);
	}

	private static long random(long begin, long end) {
		long rtn = begin + (long) (Math.random() * (end - begin));
		return rtn;
	}
}
